<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">


            <style>
                .ui-panel .ui-panel-title {
                    margin: 0 !important;
                }

                .ui-tabs .ui-tabs-nav.ui-widget-header li {
                    border: none !important;
                }
                .ui-tabs .ui-tabs-nav.ui-widget-header li a {
                    width: 88% !important;
                }

                .ui-tabs .ui-tabs-nav.ui-widget-header li.ui-state-active a, .ui-tabs .ui-tabs-nav.ui-widget-header li.ui-state-active a {
                    background-color: #82CCE1 !important;
                    background-image: -moz-linear-gradient(center top , #82CCE1, #82D4F6) !important;
                    color: #000 !important;
                    font-weight: bold;
                }
            </style>
            <h1 class="title">Prontuário</h1>
            <p:messages showDetail="true" autoUpdate="true"  /> 
            <div class="right">
                <p:clock id="clock" />  
            </div>

            <p:tabView id="tabView" orientation="left" binding="#{managerRecords.tabView}">  
                <p:tab title="Resumo">  
                    <h:form id="recordForm" >
                        <p:accordionPanel id="accordionRecord" multiple="true"  >
                            <p:tab title="Paciente"  >

                                <p:panel toggleable="true"  style="background: none; border: none;" 
                                         styleClass="container_24 clearfix ">
                                    <div class="grid_18">
                                        <div class="clear"></div>
                                        <h4><h:outputText  value="#{managerRecords.customer.gender eq 'MASCULINO' ? 'Sr. ':'Sra. '}#{managerRecords.customer.name} #{managerRecords.age ne '0' ? ' - ' : ''}#{managerRecords.age ne '0' ? managerRecords.age : ''}#{managerRecords.age ne '0' ? ' Anos' : ''}"/></h4>
                                        <div class="clear"/>
                                        <p:outputLabel value="Estado Civil:" styleClass="grid_5"/>
                                        <h:outputText styleClass="grid_5" value="#{managerRecords.customer.civilStatus}"/>

                                        <p:outputLabel value="E-mail:" styleClass="grid_4"/>
                                        <h:outputText styleClass="grid_8" value="#{managerRecords.customer.email}"/>
                                        <div class="clear"></div>
                                        <p:outputLabel value="Telefone:" styleClass="grid_5"/>
                                        <h:outputText styleClass="grid_5" value="#{managerRecords.customer.phone}"/>
                                        <p:outputLabel value="Celular:" styleClass="grid_4"/>
                                        <h:outputText styleClass="grid_8" value="#{managerRecords.customer.cellular}"/>
                                    </div>

                                    <div class="grid_5" style="text-align: center;">
                                        <p:lightBox >
                                            <h:outputLink  
                                                value="#{managerRecords.customer.annex.id eq null ? '':'show/?annex='}#{managerRecords.customer.annex.id eq null ? 'assets/images/avatar.jpg': managerRecords.customer.annex.id}" 
                                                title="#{managerRecords.customer.name}"  target="_blank" >
                                                <p:graphicImage id="avatar1" styleClass="image grid_3" 
                                                                style="width: 150px;" alt="#{managerRecords.customer.annex.id}" title="#{managerRecords.customer.annex.id}"
                                                                url="#{managerRecords.customer.annex.id eq null ? '':'show/?annex='}#{managerRecords.customer.annex.id eq null ? 'assets/images/avatar.jpg': managerRecords.customer.annex.id}" />
                                            </h:outputLink>
                                        </p:lightBox>

                                    </div>
                                </p:panel>   
                            </p:tab>
                            <p:tab id="history" title="Histórico"  >
                                <p:commandButton id="chartBtn" value="Filtros"
                                                 icon="ui-icon-search" type="button"   />
                                <p:overlayPanel for="chartBtn" style="width: 200px;">

                                    <p:panel id="filtroprontuario" styleClass="clearfix grid_24">
                                        <h:outputText value="Todos: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox value="#{managerAtendimento.showAll}">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.todosFiltros}" />
                                        </p:selectBooleanCheckbox>
                                        <div class="clear"/>
                                        <h:outputText value="Anamnese: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox  value="#{managerAtendimento.showAnamnese}" styleClass="grid_4">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.disableShowAll}" />
                                        </p:selectBooleanCheckbox>
                                        <div class="clear"/>
                                        <h:outputText value="Exame Fisico: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox value="#{managerAtendimento.showExameFisico}" styleClass="grid_4">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.disableShowAll}" />
                                        </p:selectBooleanCheckbox>
                                        <div class="clear"/>
                                        <h:outputText value="Diagnóstico: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox value="#{managerAtendimento.showDiagnostico}" styleClass="grid_4">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.disableShowAll}" />
                                        </p:selectBooleanCheckbox>
                                        <div class="clear"/>
                                        <h:outputText value="Receituário: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox value="#{managerAtendimento.showReceituario}" styleClass="grid_4">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.disableShowAll}" />
                                        </p:selectBooleanCheckbox>
                                        <div class="clear"/>
                                        <h:outputText value="Evolução/Retorno: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox value="#{managerAtendimento.showEvolucao}" styleClass="grid_4">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.disableShowAll}" />
                                        </p:selectBooleanCheckbox>
                                        <div class="clear"/>
                                        <h:outputText value="Anexos: " styleClass="grid_20"/>
                                        <p:selectBooleanCheckbox value="#{managerAtendimento.showAnexos}" styleClass="grid_4">
                                            <p:ajax update=":tabView:recordForm:accordionRecord:filtroprontuario"
                                                    listener="#{managerAtendimento.disableShowAll}" />
                                        </p:selectBooleanCheckbox>

                                        <p:commandButton value="Filtrar"
                                                         icon="ui-icon-search" 
                                                         update="@this, :tabView:recordForm:accordionRecord:historioclinico"
                                                         process="@this, :tabView:recordForm:accordionRecord:filtroprontuario"
                                                         styleClass="grid_24" />
                                    </p:panel>
                                </p:overlayPanel>
                                <div class="clear"/>

                                <!--             INICIO                   -->
                                <p:panel id="historioclinico" style="border:0px solid #fff; padding: 0px;">


                                    <ui:repeat value="#{managerRecords.recordses}" var="r">
                                        #{managerAtendimento.diaryPorRecord(r.id)}
                                        <div class="container_24 clearfix">
                                            <div class="grid_3">
                                                <p class="date">
                                                    <a href="#">
                                                        <h:outputText value="#{r.createAt}">
                                                            <f:convertDateTime pattern="MMMMM" />
                                                        </h:outputText>
                                                        <b>
                                                            <h:outputText value="#{r.createAt}">
                                                                <f:convertDateTime pattern="dd"/>
                                                            </h:outputText>

                                                        </b>
                                                        <span>
                                                            <h:outputText value="#{r.createAt}">
                                                                <f:convertDateTime pattern="yyyy"/>
                                                            </h:outputText>
                                                        </span>
                                                    </a>
                                                </p>
                                            </div>
                                            <p:panel style="background: none; margin:none;" 
                                                     styleClass="grid_20" 
                                                     collapsed="#{managerAtendimento.collapsed}"  toggleable="true" >

                                                <f:facet name="header">
                                                    <div class="grid_22 clearfix">

                                                        <div class="grid_18">
                                                            <h:outputText value="#{r.procedure.typeProcedure.name}:" styleClass="grid_5"/>
                                                            <h:outputText value="#{r.procedure.typeProcedure.name} #{r.procedure.name}" 
                                                                          styleClass="grid_19"/>
                                                            <div class="clear"/>
                                                            <h:outputText value="Médico:" styleClass="grid_5"/>
                                                            <h:outputText value="#{r.doctor.name}" styleClass="grid_13"/>
                                                            <div class="clear"/>
                                                            <h:outputText value="Médico Solicitante:" styleClass="grid_10" rendered="false"/>
                                                            <h:outputLabel value="#{managerAtendimento.diaryrecord ne null ? managerAtendimento.diaryrecord.doctorRequest.name:' - '}" 
                                                                           styleClass="grid_13"  rendered="false"/>
                                                            <div class="clear"/>
                                                            <h:outputText value="Convênio:" styleClass="grid_5"  rendered="false"/>
                                                            <h:outputText value="#{managerAtendimento.diaryrecord ne null ? managerAtendimento.diaryrecord.operator.name :' - '}" 
                                                                          styleClass="grid_13"  rendered="false"/>
                                                        </div>
                                                        <p:button icon="ui-icon-arrowreturnthick-1-w" 
                                                                  value="Retorno" outcome="createRecords"
                                                                  rendered="true"
                                                                  styleClass="grid_5">
                                                            <f:param name="c" value="#{r.customer.id}" />
                                                            <f:param name="r" value="#{r.id}" />
                                                            <f:param name="p" value="#{r.procedure eq null ? null : r.procedure.id}" />
                                                            <f:param name="d" value="#{r.doctor eq null ? null : r.doctor.id}" />
                                                        </p:button>
                                                    </div>
                                                </f:facet>

                                                <div class="grid_20" >
                                                    <div style="display: #{managerAtendimento.showAnamnese ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Anamnese</h4>

                                                        <ui:repeat value="#{r.anamneses}" var="ra">
                                                            <p:outputLabel value="Queixa Principal#{ra.id}" styleClass="grid_5"/>
                                                            <p:inputText styleClass="grid_18" readonly="true" value="#{ra.chiefComplaint}"/>
                                                            <div class="clear"/>
                                                            <p:outputLabel value="História" styleClass="grid_5"/>
                                                            <div class="grid_18">
                                                                <p:inputTextarea readonly="true" value="#{ra.descr}"/>
                                                            </div>
                                                        </ui:repeat>
                                                        <p:outputLabel value="Queixa Principal" styleClass="grid_5" rendered="#{empty r.anamneses}"/>
                                                        <p:inputText styleClass="grid_18" readonly="true" rendered="#{empty r.anamneses}"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="História" styleClass="grid_5" rendered="#{empty r.anamneses}"/>
                                                        <div class="grid_18">
                                                            <p:inputTextarea readonly="true" rendered="#{empty r.anamneses}"/>
                                                        </div>

                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showExameFisico ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Exame Físico</h4>

                                                        <div class="clear"/>
                                                        <p:outputLabel value="Altura" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.height}"/>
                                                        <p:outputLabel value="m" styleClass="grid_1"/>
                                                        <p:outputLabel value="Peso" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.weight}"/>
                                                        <p:outputLabel value="kg" styleClass="grid_1"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Batimento Cardíaco" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.heartRate}"/>
                                                        <p:outputLabel value="bpm" styleClass="grid_1"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Pressão arterial sistólica" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.systolicPressure}"/>
                                                        <p:outputLabel value="mmHg" styleClass="grid_1"/>
                                                        <p:outputLabel value="Pressão arterial Diastólica" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.diastolicPressure}"/>
                                                        <p:outputLabel value="mmHg" styleClass="grid_1"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Observações" styleClass="grid_5"/>
                                                        <div class="grid_19">
                                                            <p:inputTextarea readonly="true" value="#{r.physicalExamination.descr}"/>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showDiagnostico ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Diagnóstico</h4>

                                                        <p:outputLabel value="Diagnóstico" styleClass="grid_5"/>
                                                        <p:inputText styleClass="grid_18" readonly="true" value="#{r.diagnostic.cid}"/>
                                                        <div class="clear"/>
                                                        <p:outputLabel value="Conduta" styleClass="grid_5"/>
                                                        <div class="grid_18">
                                                            <p:inputTextarea readonly="true" value="#{r.diagnostic.descr}"/>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showReceituario ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Receituário</h4>
                                                        <p:outputLabel value="Descrição" styleClass="grid_5"/>
                                                        <div class="grid_18">
                                                            <p:inputTextarea readonly="true" value="#{r.prescription}"/>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showEvolucao ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Evolução/Retorno</h4>


                                                        <ui:repeat value="#{r.evolutions}" var="ev">

                                                            <div class="grid_6">
                                                                <p class="date">
                                                                    <a href="#">
                                                                        <h:outputText value="#{ev.dateEvolution}">
                                                                            <f:convertDateTime pattern="MMMMM" />
                                                                        </h:outputText>
                                                                        <b>
                                                                            <h:outputText value="#{ev.dateEvolution}">
                                                                                <f:convertDateTime pattern="dd"/>
                                                                            </h:outputText>

                                                                        </b>
                                                                        <span>
                                                                            <h:outputText value="#{ev.dateEvolution}">
                                                                                <f:convertDateTime pattern="yyyy"/>
                                                                            </h:outputText>
                                                                        </span>
                                                                    </a>
                                                                </p>
                                                            </div>
                                                            <div class="grid_18">
                                                                <p:outputLabel value="Data:" styleClass="grid_4" rendered="false"/>
                                                                <p:calendar showOn="button" styleClass="grid_19" 
                                                                            value="#{ev.dateEvolution}" rendered="false"
                                                                            pattern="dd/MM/yyyy" required="true"/>
                                                                <div class="clear"></div>
                                                                <p:outputLabel value="Descrição" styleClass="grid_4"/>
                                                                <div class="clear"></div>
                                                                <div class="grid_23">
                                                                    <p:inputTextarea readonly="true" value="#{ev.descr}"/>
                                                                </div> 
                                                                <div class="clear"></div>
                                                            </div>
                                                            <div class="clear"/>
                                                        </ui:repeat>


                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                    <div style="display: #{managerAtendimento.showAnexos ? 'block':'none'}">
                                                        <h4 style="color: #5593CA;">Anexos</h4>

                                                        <div class="container_24 clearfix">
                                                            <ui:repeat  value="#{r.annexs}" var="a">
                                                                <div class="grid_5">
                                                                    <h:outputLink  
                                                                        value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" 
                                                                        title="#{a.description}"  target="_blank" >

                                                                        <div style="text-align: center; width: 20%;" class="grid_4">

                                                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                                                            style="margin-left:1%; width: 100px;"
                                                                                            url="show/?annex=#{a.id}" />

                                                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                                                     a.description.replace('.png','').replace(' ','_')}" 
                                                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                                                            style="margin-left:1%; width: 100px;" 
                                                                                            url="assets/images/pdf.jpeg" />


                                                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                                                     a.description.replace('.pdf','').replace(' ','_')}" 
                                                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>


                                                                        </div>
                                                                        <f:param name="annex" value="#{a.id}"/>
                                                                    </h:outputLink>
                                                                </div>
                                                                <div class="grid_18">
                                                                    <p:outputLabel value="Laudo" styleClass="left"/>
                                                                    <div class="clear"/>
                                                                    <div class="grid_23">
                                                                        <p:inputTextarea value="#{a.laudo}" />
                                                                    </div> 
                                                                </div> 
                                                                <div class="clear"/>

                                                            </ui:repeat>
                                                        </div>
                                                        <div class="clear"/>
                                                        <hr/>
                                                    </div>
                                                </div>

                                            </p:panel>
                                        </div>
                                    </ui:repeat>
                                </p:panel>

                                <!--             FIM                   -->

                                <ui:repeat rendered="false" value="#{managerRecords.recordses}" var="r">
                                    <p:panel style="background: none; margin:none;" 
                                             styleClass="container_24 clearfix " collapsed="true" toggleable="true" >

                                        <f:facet name="header">
                                            <div class="grid_23 clearfix">
                                                <h:outputText styleClass="grid_8" value="#{r.createAt}">
                                                    <f:convertDateTime pattern="dd/MM/yyyy à's' HH:mm:ss"/>
                                                </h:outputText>
                                                <h:outputText value="#{r.procedure.name.concat((r.doctor ne null ? ' - ' : ''))
                                                                       .concat((r.doctor ne null ? r.doctor.name : ''))}" 
                                                              styleClass="grid_9"/>
                                                <p:button icon="ui-icon-arrowreturnthick-1-w" 
                                                          value="Retorno" outcome="createRecords"
                                                          styleClass="grid_6">
                                                    <f:param name="c" value="#{r.customer.id}" />
                                                    <f:param name="r" value="#{r.id}" />
                                                    <f:param name="p" value="#{r.procedure eq null ? null : r.procedure.id}" />
                                                    <f:param name="d" value="#{r.doctor eq null ? null : r.doctor.id}" />
                                                </p:button>
                                            </div>
                                        </f:facet>
                                        <div class="grid_3">
                                            <p class="date">
                                                <a href="#">
                                                    <h:outputText value="#{r.createAt}">
                                                        <f:convertDateTime pattern="MMMMM" />
                                                    </h:outputText>
                                                    <b>
                                                        <h:outputText value="#{r.createAt}">
                                                            <f:convertDateTime pattern="dd"/>
                                                        </h:outputText>

                                                    </b>
                                                    <span>
                                                        <h:outputText value="#{r.createAt}">
                                                            <f:convertDateTime pattern="yyyy"/>
                                                        </h:outputText>
                                                    </span>
                                                </a>
                                            </p>
                                        </div>
                                        <div class="grid_20" >
                                            <h4 style="color: #5593CA;">Anamnese</h4>

                                            <ui:repeat value="#{r.anamneses}" var="ra">
                                                <p:outputLabel value="Queixa Principal#{ra.id}" styleClass="grid_5"/>
                                                <p:inputText styleClass="grid_18" readonly="true" value="#{ra.chiefComplaint}"/>
                                                <div class="clear"/>
                                                <p:outputLabel value="História" styleClass="grid_5"/>
                                                <div class="grid_18">
                                                    <p:inputTextarea readonly="true" value="#{ra.descr}"/>
                                                </div>
                                            </ui:repeat>
                                            <p:outputLabel value="Queixa Principal" styleClass="grid_5" rendered="#{empty r.anamneses}"/>
                                            <p:inputText styleClass="grid_18" readonly="true" rendered="#{empty r.anamneses}"/>
                                            <div class="clear"/>
                                            <p:outputLabel value="História" styleClass="grid_5" rendered="#{empty r.anamneses}"/>
                                            <div class="grid_18">
                                                <p:inputTextarea readonly="true" rendered="#{empty r.anamneses}"/>
                                            </div>

                                            <div class="clear"/>
                                            <hr/>
                                            <h4 style="color: #5593CA;">Exame Físico</h4>

                                            <div class="clear"/>
                                            <p:outputLabel value="Altura" styleClass="grid_5"/>
                                            <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.height}"/>
                                            <p:outputLabel value="m" styleClass="grid_1"/>
                                            <p:outputLabel value="Peso" styleClass="grid_5"/>
                                            <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.weight}"/>
                                            <p:outputLabel value="kg" styleClass="grid_1"/>
                                            <div class="clear"/>
                                            <p:outputLabel value="Batimento Cardíaco" styleClass="grid_5"/>
                                            <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.heartRate}"/>
                                            <p:outputLabel value="bpm" styleClass="grid_1"/>
                                            <div class="clear"/>
                                            <p:outputLabel value="Pressão arterial sistólica" styleClass="grid_5"/>
                                            <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.systolicPressure}"/>
                                            <p:outputLabel value="mmHg" styleClass="grid_1"/>
                                            <p:outputLabel value="Pressão arterial Diastólica" styleClass="grid_5"/>
                                            <p:inputText styleClass="grid_4" readonly="true" value="#{r.physicalExamination.diastolicPressure}"/>
                                            <p:outputLabel value="mmHg" styleClass="grid_1"/>
                                            <div class="clear"/>
                                            <p:outputLabel value="Observações" styleClass="grid_5"/>
                                            <div class="grid_19">
                                                <p:inputTextarea readonly="true" value="#{r.physicalExamination.descr}"/>
                                            </div>
                                            <div class="clear"/>
                                            <hr/>
                                            <h4 style="color: #5593CA;">Diagnóstico</h4>

                                            <p:outputLabel value="Diagnóstico" styleClass="grid_5"/>
                                            <p:inputText styleClass="grid_18" readonly="true" value="#{r.diagnostic.cid}"/>
                                            <div class="clear"/>
                                            <p:outputLabel value="Conduta" styleClass="grid_5"/>
                                            <div class="grid_18">
                                                <p:inputTextarea readonly="true" value="#{r.diagnostic.descr}"/>
                                            </div>
                                            <div class="clear"/>
                                            <hr/>
                                            <h4 style="color: #5593CA;">Receituário</h4>
                                            <p:outputLabel value="Descrição" styleClass="grid_5"/>
                                            <div class="grid_18">
                                                <p:inputTextarea readonly="true" value="#{r.prescription}"/>
                                            </div>
                                            <div class="clear"/>
                                            <hr/>
                                            <h4 style="color: #5593CA;">Evolução/Retorno</h4>


                                            <ui:repeat value="#{r.evolutions}" var="ev">

                                                <div class="grid_3">
                                                    <p class="date">
                                                        <a href="#">
                                                            <h:outputText value="#{ev.dateEvolution}">
                                                                <f:convertDateTime pattern="MMMMM" />
                                                            </h:outputText>
                                                            <b>
                                                                <h:outputText value="#{ev.dateEvolution}">
                                                                    <f:convertDateTime pattern="dd"/>
                                                                </h:outputText>

                                                            </b>
                                                            <span>
                                                                <h:outputText value="#{ev.dateEvolution}">
                                                                    <f:convertDateTime pattern="yyyy"/>
                                                                </h:outputText>
                                                            </span>
                                                        </a>
                                                    </p>
                                                </div>
                                                <div class="grid_21">
                                                    <p:outputLabel value="Data:" styleClass="grid_4"/>
                                                    <p:calendar showOn="button" styleClass="grid_19" 
                                                                value="#{ev.dateEvolution}"
                                                                pattern="dd/MM/yyyy" required="true"/>
                                                    <div class="clear"></div>
                                                    <p:outputLabel value="Descrição" styleClass="grid_4"/>
                                                    <div class="grid_19">
                                                        <p:inputTextarea readonly="true" value="#{ev.descr}"/>
                                                    </div> 
                                                    <div class="clear"></div>
                                                </div>
                                                <div class="clear"/>
                                            </ui:repeat>


                                            <div class="clear"/>
                                            <hr/>
                                            <h4 style="color: #5593CA;">Anexos</h4>

                                            <div class="container_24 clearfix">
                                                <ui:repeat  value="#{r.annexs}" var="a">
                                                    <div class="grid_5">
                                                        <h:outputLink  
                                                            value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" 
                                                            title="#{a.description}"  target="_blank" >

                                                            <div style="text-align: center; width: 20%;" class="grid_4">

                                                                <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                                                style="margin-left:1%; width: 100px;"
                                                                                url="show/?annex=#{a.id}" />

                                                                <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                                         a.description.replace('.png','').replace(' ','_')}" 
                                                                                style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                                                <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                                                style="margin-left:1%; width: 100px;" 
                                                                                url="assets/images/pdf.jpeg" />


                                                                <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                                         a.description.replace('.pdf','').replace(' ','_')}" 
                                                                                style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>


                                                            </div>
                                                            <f:param name="annex" value="#{a.id}"/>
                                                        </h:outputLink>
                                                    </div>
                                                    <div class="grid_18">
                                                        <p:outputLabel value="Laudo" styleClass="left"/>
                                                        <div class="clear"/>
                                                        <div class="grid_23">
                                                            <p:inputTextarea value="#{a.laudo}" />
                                                        </div> 
                                                    </div> 
                                                    <div class="clear"/>

                                                </ui:repeat>
                                            </div>
                                            <div class="clear"/>
                                            <hr/>
                                        </div>

                                    </p:panel>

                                </ui:repeat>
                            </p:tab>
                        </p:accordionPanel>
                    </h:form>
                </p:tab>  
                <p:tab title="Anamnese" id="tabAnamnese">
                    <h:form id="anamneseForm">
                        <h1 class="title">Anamnese</h1>
                        <p:panel toggleable="true"  style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">
                            <div class="clear"/>
                            <p:outputLabel value="Queixa Principal" styleClass="grid_4"/>
                            <p:inputText styleClass="grid_19" value="#{managerRecords.anamnese.chiefComplaint}"/>

                            <p:outputLabel value="História" styleClass="grid_4"/>
                            <div class="grid_19">
                                <p:inputTextarea  value="#{managerRecords.anamnese.descr}"/>
                            </div>

                        </p:panel>
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" icon="ui-icon-disk"
                                             process="@form" update=":tabView, @form" iconPos="right"
                                             actionListener="#{managerRecords.saveAnamnese()}"
                                             styleClass="ui-priority-primary" />
                        </div>
                    </h:form>
                </p:tab>  
                <p:tab title="Exame Físico/Nutricional">  
                    <h:form id="physicalForm">
                        <h1 class="title">Exame Fisíco/Nutricional</h1>
                        <p:panel toggleable="true"  style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">
                            <div class="clear"/>
                            <p:outputLabel value="Altura" styleClass="grid_5"/>
                            <p:inputText id="altura" styleClass="grid_4" value="#{managerRecords.physicalExamination.height}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                                <p:ajax event="blur" update=":tabView:physicalForm:imc,
                                        :tabView:physicalForm:pesoideal" 
                                        process="@this, :tabView:physicalForm:altura, :tabView:physicalForm:peso" 
                                        listener="#{managerRecords.calcImc()}"/>
                            </p:inputText>
                            <p:outputLabel id="peso" value="Peso" styleClass="grid_2"  style="margin-left: 24px;"/>
                            <p:inputText styleClass="grid_4" value="#{managerRecords.physicalExamination.weight}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                                <p:ajax event="blur" update=":tabView:physicalForm:imc,
                                        :tabView:physicalForm:pesoideal, :tabView:physicalForm:tmb, :tabView:physicalForm:vet" 
                                        process="@this, :tabView:physicalForm:altura, :tabView:physicalForm:peso" 
                                        listener="#{managerRecords.calcImc()}"/>
                            </p:inputText>

                            <div class="clear"/>
                            <p:outputLabel value="Peso Ideal" styleClass="grid_5"/>
                            <p:inputText id="pesoideal" styleClass="grid_4" readonly="true" 
                                         value="#{managerRecords.physicalExamination.pesoIdeal}"/>

                            <p:outputLabel value="IMC" styleClass="grid_2"  style="margin-left: 24px;"/>
                            <p:inputText id="imc" styleClass="grid_11" readonly="true" style="width: 45.2%;"
                                         value="#{managerRecords.physicalExamination.imc.toString().concat(' - ').concat(managerRecords.physicalExamination.imcClassificacao.nome)}"/>

                            <div class="clear"/>
                            <p:outputLabel value="Batimento Cardíaco" styleClass="grid_5"/>
                            <p:inputText styleClass="grid_4" value="#{managerRecords.physicalExamination.heartRate}"/>

                            <p:outputLabel value="PAS" styleClass="grid_2" style="margin-left: 24px;"/>
                            <p:inputText styleClass="grid_4" title="Pressão arterial sistólica" value="#{managerRecords.physicalExamination.systolicPressure}"/>

                            <p:outputLabel value="PAD" styleClass="grid_3"/>
                            <p:inputText styleClass="grid_4" title="Pressão arterial Diastólica" value="#{managerRecords.physicalExamination.diastolicPressure}"/>

                            <div class="clear"/>

                            <p:outputLabel value="Fator Atividade" styleClass="grid_5"/>
                            <div class="grid_4">
                                <p:selectOneMenu style="width: 110%;" value="#{managerRecords.physicalExamination.fatorAtividadeFisica}" >
                                    <p:ajax listener="#{managerRecords.calcularVet()}" process="@this" 
                                            update=":tabView:physicalForm:tmb, :tabView:physicalForm:vet" />
                                    <f:selectItem itemValue="#{null}" itemLabel="" />
                                    <f:selectItems value="#{managerRecords.selectFatorAtividadeFisica()}"/>
                                </p:selectOneMenu>
                            </div>

                            <p:outputLabel value="TMB" styleClass="grid_2" style="margin-left: 35px;"/>
                            <p:inputText id="tmb" styleClass="grid_4" title="Taxa Metabólica Basal" readonly="true" 
                                         value="#{managerRecords.physicalExamination.tmb}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="VET" styleClass="grid_2" style="margin-left: 35px;"/>
                            <p:inputText id="vet" styleClass="grid_4" title="Valor Energético Total" readonly="true"
                                         value="#{managerRecords.physicalExamination.vet}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                            </p:inputText>

                            <div class="clear"/>

                            <p:outputLabel value="PCT" styleClass="grid_5"/>
                            <p:inputText styleClass="grid_4" title="Prega Cutanea Tricpital" value="#{managerRecords.physicalExamination.pct}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="CB" styleClass="grid_2" style="margin-left: 24px;"/>
                            <p:inputText styleClass="grid_4" title="Circunferência Braço" value="#{managerRecords.physicalExamination.cb}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="CC" styleClass="grid_3"/>
                            <p:inputText styleClass="grid_4" title="Circunferência Cintura" value="#{managerRecords.physicalExamination.cc}"
                                         onkeypress="jQuery(this).autoNumeric({aSign:'',aSep: '.', aDec: ','} );">
                                <f:convertNumber type="number" locale="pt,BR"/>
                            </p:inputText>

                            <div class="clear"/>

                            <p:outputLabel value="% PCT" styleClass="grid_5"/>
                            <p:inputText styleClass="grid_4" title="% de Prega Cutanea Tricpital" 
                                         value="#{managerRecords.physicalExamination.pctPorcentagem}"
                                         onkeypress="jQuery(this).autoNumeric({pSign: 's',aSign: '%', aSep: '.', aDec: ','} );">
                                <f:convertNumber type="percent" locale="pt,BR"/>
                            </p:inputText>

                            <p:outputLabel value="% CB" styleClass="grid_2"  style="margin-left: 24px;"/>
                            <p:inputText styleClass="grid_4" title="% Circunferência Braço" 
                                         value="#{managerRecords.physicalExamination.cbPorcentagem}"
                                         onkeypress="jQuery(this).autoNumeric({pSign: 's',aSign: '%', aSep: '.', aDec: ','} );">
                                <f:convertNumber type="percent" locale="pt,BR"/>
                            </p:inputText>

                            <div class="clear"/>

                            <p:outputLabel value="Estado Nutricional" styleClass="grid_5"/>
                            <div class="grid_19">
                                <p:inputTextarea  value="#{managerRecords.physicalExamination.estadoNutricional}"/>
                            </div>
                            <div class="clear"/>
                            <p:outputLabel value="Observações" styleClass="grid_5"/>
                            <div class="grid_19">
                                <p:inputTextarea  value="#{managerRecords.physicalExamination.descr}"/>
                            </div>

                        </p:panel>
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" icon="ui-icon-disk" iconPos="right"
                                             process="@form" update=":tabView, @form"
                                             actionListener="#{managerRecords.savePhysical()}"
                                             styleClass="ui-priority-primary" />
                        </div>
                    </h:form>
                </p:tab>  
                <p:tab title="Diagnóstico">  
                    <h:form id="diagnosticForm">
                        <h1 class="title">Diagnóstico</h1>
                        <p:panel toggleable="true"  style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">
                            <p:outputLabel value="Diagnóstico" styleClass="grid_5"/>
                            <p:inputText styleClass="grid_18" value="#{managerRecords.diagnostic.cid}"/>
                            <div class="clear"/>
                            <p:outputLabel value="Conduta" styleClass="grid_5"/>
                            <div class="grid_18">
                                <p:inputTextarea  value="#{managerRecords.diagnostic.descr}"/>
                            </div>
                        </p:panel>
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" icon="ui-icon-disk" iconPos="right"
                                             process="@form" update=":tabView, @form"
                                             actionListener="#{managerRecords.saveDiagnostic()}"
                                             styleClass="ui-priority-primary" />
                        </div>
                    </h:form>
                </p:tab>  
                <p:tab title="Odontograma" rendered="#{managerRecords.procedure.groupProcedure eq 'ODONTOLOGIA'}">
                    <h:form id="odontogramaForm">
                        <h1 class="title">Odontogramas</h1>
                        <p:panel id="resultPanel" style="background: none; border: none;" 
                                 styleClass="container_24 clearfix " >

                            <p:button value="Novo Odontograma" styleClass="ui-priority-primary right grid_7" 
                                      icon="ui-icon-plus" outcome="odontograma.xhtml" >
                                <f:param name="dw" value="#{managerRecords.diarywaitinglineid}" />
                            </p:button>

                            <p:dataTable id="tablePac" var="odo" value="#{managerOdontograma.odontogramas}" 
                                         styleClass="grid_24"
                                         rowIndexVar="rowid"
                                         rowKey="#{r.id}"
                                         rows="5" paginator="true"  
                                         paginatorPosition="bottom"
                                         emptyMessage="Nenhum registro"
                                         >  
                                <f:facet name="header">
                                    Odontogramas
                                </f:facet>
                                <p:column headerText="Ação" width="75">
                                    <p:button icon="ui-icon-search" title="Visualizar" alt="Visualizar"
                                              href="odontograma.xhtml?o=#{odo.id}" 
                                              style="width: 25px; position: relative;"/>

                                </p:column>
                                <p:column headerText="Tipo" width="400">  
                                    <h:outputText value="#{odo.orcamento ? 'Orçamento':'Tratamento'}"/>
                                </p:column>  
                                <p:column headerText="Realizado em" width="400">  
                                    <h:outputText value="#{odo.dataCriacao}">  
                                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                                    </h:outputText>
                                </p:column>
                                <p:column headerText="Observações" width="400">  
                                    <h:outputText value="#{odo.observacao}"/>
                                </p:column>  


                            </p:dataTable> 
                        </p:panel>
                    </h:form>
                </p:tab>
                <p:tab title="Receituário"> 
                    <h:form id="prescriptionForm">
                        <h1 class="title">Receituário</h1>
                        <p:panel toggleable="true"  style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">

                            <p:commandButton value="Resgatar anterior" icon="ui-icon-arrowreturnthick-1-w"
                                             process="@this" update="@this, prescription" actionListener="#{managerRecords.lastPrescriptionRecords()}"
                                             styleClass="right" />
                            <div class="grid_12 right">
                                <p:commandButton value="Receituário Comum" icon="ui-icon-print"
                                               ajax="false"  update="@form" process="@form" 
                                               onclick="this.form.target='_blank'" alt="Imprimir Receituário Comum" title="Imprimir Receituário Comum"
                                               actionListener="#{managerRecords.reportPreescription()}"/>
                                <p:commandButton value="Receituário Especial"
                                                ajax="false"  update="@form" process="@form" 
                                                onclick="this.form.target='_blank'" alt="Imprimir Receituário Especial" title="Imprimir Receituário Especial"
                                                actionListener="#{managerRecords.reportPreescriptionEspecial()}"
                                                icon="ui-icon-print"/>
                            </div>
                            <br/>
                            <div class="clear"/>
                            <p:outputLabel value="Descrição" styleClass="grid_3"/>
                            <div class="grid_20">
                                <p:inputTextarea id="prescription" value="#{managerRecords.records.prescription}"/>
                            </div>



                            <p:commandButton value="Enviar por e-mail" icon="ui-icon-document"
                                             process="@this" update="@this" ajax="false" rendered="false"
                                             styleClass="right" />
                        </p:panel>
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" icon="ui-icon-disk" iconPos="right"
                                             process="@form" update=":tabView, @form" 
                                             actionListener="#{managerRecords.savePrescription()}"
                                             styleClass="ui-priority-primary" />
                            <p:commandButton value="Finalizar" icon="ui-icon-disk" iconPos="right"
                                             process="@form" update=":tabView, @form" 
                                             actionListener="#{managerRecords.savePreescriptionAndFinaly()}"
                                             styleClass="ui-priority-primary" />
                        </div>
                    </h:form>
                </p:tab>
                <p:tab title="Evolução/Retorno"> 
                    <h:form id="evolutionForm">
                        <h1 class="title">Evolução/Retorno</h1>
                        <p:panel toggleable="true"  style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">

                            <ui:repeat rendered="#{!empty managerRecords.evolutions and managerRecords.evolutions.size() >= 1}" value="#{managerRecords.evolutions}" var="ev">

                                <div class="grid_3">
                                    <p class="date">
                                        <a href="#">
                                            <h:outputText value="#{ev.dateEvolution}">
                                                <f:convertDateTime pattern="MMMMM" />
                                            </h:outputText>
                                            <b>
                                                <h:outputText value="#{ev.dateEvolution}">
                                                    <f:convertDateTime pattern="dd"/>
                                                </h:outputText>

                                            </b>
                                            <span>
                                                <h:outputText value="#{ev.dateEvolution}">
                                                    <f:convertDateTime pattern="yyyy"/>
                                                </h:outputText>
                                            </span>
                                        </a>
                                    </p>
                                </div>
                                <div class="grid_21">
                                    <p:outputLabel value="Data:" styleClass="grid_3"/>
                                    <p:calendar readonly="true" styleClass="grid_21" 
                                                value="#{ev.dateEvolution}" pattern="dd/MM/yyyy"/>
                                    <div class="clear"/>
                                    <p:outputLabel value="Descrição" styleClass="grid_3"/>
                                    <div class="grid_20">
                                        <p:inputTextarea readonly="true" value="#{ev.descr}"/>
                                    </div> 
                                    <div class="clear"/>
                                </div>
                                <div class="clear"/>
                                <hr/>
                            </ui:repeat>

                            <div>
                                <p class="date" 
                                   style="height:30px; width: 100%;background-repeat: repeat-x;">
                                    <h:outputText value="Adicionar Evolução/Retorno"/>
                                </p>
                                <br/><br/><br/>
                            </div>

                            <div class="clear"/>
                            <div class="grid_3">

                            </div>
                            <div class="grid_21">
                                <p:outputLabel value="Data:" styleClass="grid_3"/>
                                <p:calendar showOn="button" styleClass="grid_8" 
                                            value="#{managerRecords.evolution.dateEvolution}"
                                            pattern="dd/MM/yyyy" />
                                <div class="clear"/>
                                <p:outputLabel value="Descrição" styleClass="grid_3"/>
                                <div class="grid_20">
                                    <p:inputTextarea value="#{managerRecords.evolution.descr}"/>
                                </div> 
                            </div>


                        </p:panel>
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" icon="ui-icon-disk" iconPos="right"
                                             process="@form" update=":tabView, @form"
                                             actionListener="#{managerRecords.saveEvolution()}"
                                             styleClass="ui-priority-primary" />
                        </div>
                        <br/><br/><br/><br/>
                        <div>
                            <p class="date" 
                               style="height:30px; width: 100%;background-repeat: repeat-x;">
                                <h:outputText value="Histórico de Evoluções por Atendimento"/>
                            </p>
                            <br/><br/><br/>

                            <p:panel id="historioclinico" style="border:0px solid #fff; padding: 0px;">


                                <ui:repeat value="#{managerRecords.recordses}" var="r">

                                    #{managerAtendimento.diaryPorRecord(r.id)}
                                    <div class="container_24 clearfix">
                                        <div class="grid_3">
                                            <p class="date">
                                                <a href="#">
                                                    <h:outputText value="#{r.createAt}">
                                                        <f:convertDateTime pattern="MMMMM" />
                                                    </h:outputText>
                                                    <b>
                                                        <h:outputText value="#{r.createAt}">
                                                            <f:convertDateTime pattern="dd"/>
                                                        </h:outputText>

                                                    </b>
                                                    <span>
                                                        <h:outputText value="#{r.createAt}">
                                                            <f:convertDateTime pattern="yyyy"/>
                                                        </h:outputText>
                                                    </span>
                                                </a>

                                            </p>
                                        </div>
                                        <p:panel style="background: none; margin:none;" 
                                                 styleClass="grid_20"  >

                                            <f:facet name="header">
                                                <div class="grid_22 clearfix">

                                                    <div class="grid_18">
                                                        <h:outputText value="#{r.procedure.typeProcedure.name}:" styleClass="grid_5"/>
                                                        <h:outputText value="#{r.procedure.typeProcedure.name} #{r.procedure.name}" 
                                                                      styleClass="grid_19"/>
                                                        <div class="clear"/>
                                                        <h:outputText value="Médico:" styleClass="grid_5"/>
                                                        <h:outputText value="#{r.doctor.name}" styleClass="grid_13"/>
                                                        <div class="clear"/>
                                                        <h:outputText value="Médico Solicitante:" styleClass="grid_10" rendered="false"/>
                                                        <h:outputLabel value="#{managerAtendimento.diaryrecord ne null ? managerAtendimento.diaryrecord.doctorRequest.name:' - '}" 
                                                                       styleClass="grid_13"  rendered="false"/>
                                                        <div class="clear"/>
                                                        <h:outputText value="Convênio:" styleClass="grid_5"  rendered="false"/>
                                                        <h:outputText value="#{managerAtendimento.diaryrecord ne null ? managerAtendimento.diaryrecord.operator.name :' - '}" 
                                                                      styleClass="grid_13"  rendered="false"/>


                                                    </div>

                                                    <p:button icon="ui-icon-arrowreturnthick-1-w" 
                                                              value="Visualizar" outcome="createRecords"
                                                              rendered="true"
                                                              styleClass="grid_5">
                                                        <f:param name="c" value="#{r.customer.id}" />
                                                        <f:param name="r" value="#{r.id}" />
                                                        <f:param name="p" value="#{r.procedure eq null ? null : r.procedure.id}" />
                                                        <f:param name="d" value="#{r.doctor eq null ? null : r.doctor.id}" />
                                                    </p:button>

                                                </div>
                                            </f:facet>

                                            <div class="grid_20" >
                                                <div>
                                                    <h4 style="color: #5593CA; display: #{empty r.evolutions ? 'none':'block'}">Evolução/Retorno</h4>

                                                    <h:outputLabel value="Não há evolução"
                                                                   styleClass="grid_7"
                                                                   rendered="#{empty r.evolutions}"/>

                                                    <ui:repeat value="#{r.evolutions}" var="ev">
                                                        <div class="grid_6">
                                                            <p class="date">
                                                                <a href="#">
                                                                    <h:outputText value="#{ev.dateEvolution}">
                                                                        <f:convertDateTime pattern="MMMMM" />
                                                                    </h:outputText>
                                                                    <b>
                                                                        <h:outputText value="#{ev.dateEvolution}">
                                                                            <f:convertDateTime pattern="dd"/>
                                                                        </h:outputText>

                                                                    </b>
                                                                    <span>
                                                                        <h:outputText value="#{ev.dateEvolution}">
                                                                            <f:convertDateTime pattern="yyyy"/>
                                                                        </h:outputText>
                                                                    </span>
                                                                </a>
                                                            </p>
                                                        </div>
                                                        <div class="grid_18">
                                                            <p:outputLabel value="Data:" styleClass="grid_4" rendered="false"/>
                                                            <p:calendar showOn="button" styleClass="grid_19" 
                                                                        value="#{ev.dateEvolution}" rendered="false"
                                                                        pattern="dd/MM/yyyy" required="true"/>
                                                            <div class="clear"></div>
                                                            <p:outputLabel value="Descrição" styleClass="grid_4"/>
                                                            <div class="clear"></div>
                                                            <div class="grid_23">
                                                                <p:inputTextarea readonly="true" value="#{ev.descr}"/>
                                                            </div> 
                                                        </div>
                                                        <div class="clear"/>
                                                    </ui:repeat>
                                                    <div class="clear"/>
                                                    <hr/>
                                                </div>
                                            </div>

                                        </p:panel>
                                    </div>
                                </ui:repeat>
                            </p:panel>
                        </div>
                    </h:form>
                </p:tab>  

                <p:tab title="Anexos">  
                    <h:form id="annexForm" enctype="multipart/form-data">
                        <h1 class="title">Anexo</h1>
                        <p:panel toggleable="true" id="panelAnnex"  style="background: none; border: none;" 
                                 styleClass="container_24 clearfix ">
                            <p:fileUpload 
                                mode="advanced"  
                                label="Anexar"
                                fileUploadListener="#{managerRecords.handle}"
                                multiple="true" 
                                auto="true"
                                invalidFileMessage="Tipo de arquivo não suportado."
                                invalidSizeMessage="Tamanho do arquivo não é suportado"
                                uploadLabel="Enviar"
                                cancelLabel="Cancelar"
                                immediate="true"
                                update="@form"
                                allowTypes="/(\.|\/)(gif|tif|jpe?g|png|pdf)$/"/> 
                        </p:panel>
                        <div class="container_24 clearfix">
                            <ui:repeat id="images"  value="#{managerRecords.annexs}" var="a">
                                <div class="grid_5">
                                    <h:outputLink  
                                        value="#{a.type ne 'application/pdf' ? 'viewImage.xhtml':'show'}" 
                                        title="#{a.description}"  target="_blank" >

                                        <div style="text-align: center; width: 20%;" class="grid_4">

                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type ne 'application/pdf'}"
                                                            style="margin-left:1%; width: 100px;"
                                                            url="show/?annex=#{a.id}" />

                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                     a.description.replace('.png','').replace(' ','_')}" 
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type ne 'application/pdf'}"/>

                                            <p:graphicImage styleClass="image grid_3" rendered="#{a.type eq 'application/pdf'}"
                                                            style="margin-left:1%; width: 100px;" 
                                                            url="assets/images/pdf.jpeg" />


                                            <p:outputLabel  value="#{a.description.length() ge 10 ? a.description.substring(0, 10).concat('...') : 
                                                                     a.description.replace('.pdf','').replace(' ','_')}" 
                                                            style="margin-left:1%; width: 100px;" rendered="#{a.type eq 'application/pdf'}"/>


                                        </div>
                                        <f:param name="annex" value="#{a.id}"/>
                                    </h:outputLink>
                                </div>
                                <div class="grid_18">
                                    <p:outputLabel value="Laudo" styleClass="left"/>
                                    <div class="clear"/>
                                    <div class="grid_23">
                                        <p:inputTextarea value="#{a.laudo}"/>
                                    </div> 
                                </div> 
                                <div class="clear"/>

                            </ui:repeat>
                        </div>
                        <div class="buttonAction">
                            <p:commandButton value="Salvar" icon="ui-icon-disk"
                                             process="@form" update=":tabView, @form" iconPos="right"
                                             actionListener="#{managerRecords.saveAnnex()}"
                                             styleClass="ui-priority-primary" />
                        </div>
                    </h:form>

                </p:tab>  
            </p:tabView> 
        </ui:define>
    </ui:composition>

</html>






